package com.shujia.mr.writable;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

// NullWritable:表示输出的Key为空，不是null
public class MyWritableReducer extends Reducer<Text,Student,Student, NullWritable> {
    @Override
    protected void reduce(Text key, Iterable<Student> values, Reducer<Text, Student, Student, NullWritable>.Context context) throws IOException, InterruptedException {
        for (Student student : values) {
            // NullWritable对象可以通过get函数获取，和其他的序列化类不一样
            context.write(student,NullWritable.get());
        }
    }
}
